package cn.larry.tools.browser;

import java.util.HashMap;
import java.util.Map;

/**
 * Larry
 * 2021/11/12 09:58
 * 对应的浏览器检验规则：包含的关键字符串
 * 【P：判断浏览器类型，包含关键字符串的检验并不一定正确】
 *
 * @Version 1.0
 */
public enum BrowserUserAgentEnum {

    USERAGENT_MOBILE_PHONE_ALIPAY(BrowserTypeEnum.MOBILE_PHONE_ALIPAY.name(), new String[]{"AlipayClient", "Mobile"}),
    USERAGENT_MOBILE_PHONE_WECHAT(BrowserTypeEnum.MOBILE_PHONE_WECHAT.name(), new String[]{"MicroMessenger" , "Mobile"}),
    USERAGENT_MOBILE_PHONE_UNIONPAY(BrowserTypeEnum.MOBILE_PHONE_UNIONPAY.name(), new String[]{"UnionPay"});

    /**
     * 浏览器类型，参考'BrowserTypeEnum.java'
     */
    private String browserType;

    /**
     * 关键的子字符串
     */
    private String[] pivotalSubUserAgents;


    public static final Map<String, String[]> BROWSERUSERAGENT_MAP = new HashMap<>();

    static {
        for (BrowserUserAgentEnum userAgentEnum : BrowserUserAgentEnum.values()) {
            BROWSERUSERAGENT_MAP.put(userAgentEnum.browserType, userAgentEnum.pivotalSubUserAgents);
        }
    }

    private BrowserUserAgentEnum(String browserType, String[] pivotalSubUserAgents) {
        this.browserType = browserType;
        this.pivotalSubUserAgents = pivotalSubUserAgents;
    }


}
